package com.source.multithread.atomicc;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author wengqy
 * @Date 2020/12/25
 */
public class AtomicIntegerDemo {
    public static void main(String[] args) {
        AtomicInteger  atomicInteger  = new AtomicInteger(5);
        System.out.println(atomicInteger.compareAndSet(5, 2020));
        System.out.println(atomicInteger.get());

        System.out.println(atomicInteger.compareAndSet(2020, 5));
        System.out.println(atomicInteger.get());

        System.out.println(atomicInteger.compareAndSet(5, 2088));
        System.out.println(atomicInteger.get());


    }
}
